package com.bk.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bk.entity.RoleInfo;
import com.bk.service.GetRoleInfoListService;
import com.bk.util.ReturnUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author czl
 */
@RestController
@Api(value = "RoleList")
public class RoleInfoListController {

	@Autowired
	private GetRoleInfoListService getRoleInfoListService;

	@GetMapping("/getAllRoleList") /** 获取所有的角色列表 */
	@ApiOperation(value = "角色权限列表", notes = "获取所有的角色权限RestFul风格的请求")
	public ReturnUtil<RoleInfo> getRoleInfoList() {
		List<RoleInfo> allRoleInfoList = getRoleInfoListService.getAllRoleInfoList();
		ReturnUtil<RoleInfo> result = new ReturnUtil<RoleInfo>(000000, "获取所有角色权限", allRoleInfoList);
		return result;
	}
	
	@GetMapping("/getAllNoRoleList") /** 获取所有的角色列表 */
	public ReturnUtil<RoleInfo> getAllNoRoleList() {
		List<RoleInfo> allRoleInfoList = getRoleInfoListService.getAllNoRoleList();
		ReturnUtil<RoleInfo> result = new ReturnUtil<RoleInfo>(000000, "获取所有未认证角色清单", allRoleInfoList);
		return result;
	}
	
	 
	@PostMapping("/updateRole/{flag}") /** 激活或者移除角色   flag 0移除  1激活 */
	public ReturnUtil<RoleInfo> updateRole(@RequestParam("roleAuths") String roleAuths,@PathVariable int flag) {
		ReturnUtil<RoleInfo> ru = getRoleInfoListService.updateRole(roleAuths,flag);
		return ru;
	}
	
	
	@GetMapping("/getRoleInfoByAuthority") /**获取角色信息 */
	public RoleInfo getRoleInfoByAuthority(@RequestParam("authority") String authority) {
		RoleInfo roleInfo = getRoleInfoListService.getRoleInfoByAuthority(authority);
		return roleInfo; 
	}
}
